module.exports = {
  plugins: [
    require("autoprefixer")({
      // 直接定义 browserslist，不要 require .browserslistrc 文件
      overrideBrowserslist: ["last 2 versions", "iOS >= 8", "Android >= 4.4"],
    }),
    require("postcss-rpx-transform")({
      transform: (x) => 2 * x, // 1px → 2rpx
      precision: 5,
      mediaQuery: false,
    }),
    // 替代 postcss-remove-calc
    (root) => {
      root.walkDecls((decl) => {
        if (decl.value.includes("calc(")) {
          decl.value = decl.value.replace(/calc\(.*?\)/g, "");
        }
      });
    },
    // 替代 postcss-remove-vars
    (root) => {
      root.walkDecls((decl) => {
        if (decl.value.includes("var(")) {
          decl.value = decl.value.replace(/var\(.*?\)/g, "");
        }
      });
    },
  ],
};
